import userService from '../service'
class UserController {
    static async login(ctx) {

        let {
            password,
            username
        } = ctx.request.body;
        ctx.body = await userService.login(password, username)
    }

    static async register(ctx) {
        let {
            password,
            username,
            nickename,
            phone,
            role
        } = ctx.request.body;
        ctx.body = await userService.register({
            password,
            username,
            nickename,
            phone,
            role
        })
    }

    static async update(ctx) {
        let {
            id,
            password,
            username,
            nickname,
            phone,
            role
        } = ctx.request.body;
        ctx.body = await userService.update({
            id,
            password,
            username,
            nickname,
            phone,
            role
        })
    }

    static async logout(ctx) {
        let {
            id
        } = ctx.request.body;
        ctx.body = await userService.logout(id)
    }
}

export default UserController;